package com.gimi.cloud.jimi.commonService.util;

import com.gimi.cloud.jimi.entity.core.ApiConfig;

import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;



/**
 * @author fxx
 * @date 2012-8-29
 * @version 2.0
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public class Global {

	public static String VERSION = "v2.0.0.0";

	public static final String DB_PREFIX = "rd_";

	public static Map BORROWCONFIG;
	public static Map<String,ApiConfig> API_CONFIG = new HashMap<String,ApiConfig>();//api配置文件

	/**
	 * 配置文件对应表
	 */
	public static Map<String, String> SPP_MAP = new HashMap<String, String>();
	

	public static Set TRADE_NO_SET = Collections.synchronizedSet(new HashSet());
	public static Set TENDER_SET = Collections.synchronizedSet(new HashSet());
	public static Map TENDER_MAP = Collections.synchronizedMap(new HashMap<String, String>());
	public static Map<String, Object> SESSION_MAP = Collections.synchronizedMap(new HashMap<String, Object>());
    //接口回调处理结果
	public static Map RESULT_MAP=Collections.synchronizedMap(new HashMap<String,String>());

	public static ThreadLocal<String> IP_THREADLOCAL = new ThreadLocal<String>();

	public static final ThreadLocal transferThreadLocal = new ThreadLocal();


	public static Map SMSTYPECONFIG;

	public static Map NOTICE_TYPE_CONFIG;




	public static String getIP() {
		Object retObj = Global.IP_THREADLOCAL.get();
		return retObj == null ? "" : retObj.toString();
	}

	/**
	 * 获得通过key,获得s_properties表中的值
	 * @param key
	 * @return
	 */
	public static String getPropertiesValue(String key) {
		return Global.SPP_MAP.get(key);
	}
	




	public static Map<String, Object> getTransfer() {
		Map<String, Object> map = (Map<String, Object>) transferThreadLocal.get();
		if (map == null) {
			map = new HashMap<String, Object>();
			transferThreadLocal.set(map);
		}
		return map;
	}

	public static void setTransfer(String key, Object value) {
		Map<String, Object> map = getTransfer();
		map.put(key, value);
		transferThreadLocal.set(map);
	}

}
